home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / Source, The - Issue 5 (1993)(Epsilon)[WB].zip / Source, The - Issue 5 (1993)(Epsilon)[WB].adf / Source / Music / GMod.lha / gmod.i < prev    next >
Text File  |  1992-05-25  |  5KB  |  110 lines

  1. *** Header file used for creating and calling GMOD modules ***
  2. * Public domain by Bryan Ford
  3.  
  4.         ifnd    BRY_GMOD_I
  5. BRY_GMOD_I      set     1
  6.  
  7.         ifnd    EXEC_TYPES_I
  8.         include "exec/types.i"
  9.         endc
  10.  
  11.  
  12. *** This is the layout of the first part of every GMOD module.
  13.  STRUCTURE      GMOD,0
  14.         ; The first four longwords contain various important values.
  15.         ULONG   gmod_ID                 ; Must be 'GMOD'
  16.         ULONG   gmod_Maker              ; ID of creator program (ASCII, like IFF ID's)
  17.         ULONG   gmod_LoadAddress        ; Address at which to load module (0L = any)
  18.         ULONG   gmod_MaxVecOfs          ; Offset of end of vector table (numvecs+4)*4
  19.  
  20.         ; From here on are the entrypoints
  21.         ; (actual instructions, not just vector pointers)
  22.         LONG    gmod_InitMusic          ; Initialize the module
  23.         LONG    gmod_StartMusic         ; Start playing (d0.l = song number)
  24.         LONG    gmod_StopMusic          ; Stop playing
  25.         LONG    gmod_EndMusic           ; Shut down the module
  26.         LONG    gmod_NotePlayer         ; Tell the module to use a NotePlayer (a0 = NotePlayer)
  27.         LONG    gmod_ContinueMusic      ; Restart after pause
  28.         LONG    gmod_VBlank50           ; VBlank interrupt (50Hz)
  29.         LONG    gmod_VBlank60           ; VBlank interrupt (60Hz)
  30.         LONG    gmod_Audio0             ; Channel 0 audio interrupt
  31.         LONG    gmod_Audio1             ; Channel 1 audio interrupt
  32.         LONG    gmod_Audio2             ; Channel 2 audio interrupt
  33.         LONG    gmod_Audio3             ; Channel 3 audio interrupt
  34.         LONG    gmod_GetNumSongs        ; Get number of songs (d0.l)
  35.         LONG    gmod_GetSongName        ; Get description of a song (d1.l) into (d0.p)
  36.         LONG    gmod_GetSongAuthor      ; Get the name of a song's author (d1.l) into (d0.p)
  37.         LONG    gmod_GetFrequency       ; Get the timing frequency for the song (d0.l)
  38.         LONG    gmod_TimerTick          ; Routine to call at specified frequency
  39.         LONG    gmod_GetMakerName       ; Get name of creator program
  40.         LONG    gmod_Hook               ; Specify a Hook to call on various events
  41.         LONG    gmod_Jump               ; Jump somewhere else in song
  42.         LONG    gmod_SetVolume          ; Set master volume ($0-$100)
  43.         LONG    gmod_GetScroll          ; Get scroll text
  44.         LABEL   gmod_SIZEOF             ; This will grow!
  45.  
  46.         ; Flags for the gmod_Hook call - similar to Intuition's IDCMP flags
  47.         BITDEF  GMODH,REPEAT,0          ; Call when music repeats
  48.         BITDEF  GMODH,SEQUENCE,1        ; Call when sequence changes
  49.  
  50.  
  51. *** Use these macros to help when playing GMOD modules.
  52. *** All of them assume that the pointer to the GMOD module is in a5.
  53.  
  54. * Branch if a vector offset (gmod_xxx) is in range
  55. gmodbin         macro   ; DReg,label
  56.                 cmp.l   gmod_MaxVecOfs(a5),\1
  57.                 bcs     \2
  58.                 endm
  59.  
  60. * Branch if a vector offset (gmod_xxx) is out of range
  61. gmodbout        macro   ; DReg,label
  62.                 cmp.l   gmod_MaxVecOfs(a5),\1
  63.                 bcc     \2
  64.                 endm
  65.  
  66. * Call a GMOD vector WITHOUT checking - you must first make sure it's there!
  67. gmodcall        macro   ; DReg
  68.                 jsr     0(a5,\1)
  69.                 endm
  70.  
  71. * Same as gmodcall, but with an immediate (as opposed to register) vector offset
  72. gmodcalli       macro   ; Offset
  73.                 jsr     \1(a5)
  74.                 endm
  75.  
  76. * This is what you'll usually use when calling GMOD entrypoints -
  77. * it first checks to make sure the entrypoint is available, THEN calls
  78. * it.  The GMOD pointer must be in a5, and the vector offset must
  79. * be in some data register.
  80. gmodmaycall     macro   ; DReg
  81.                 cmp.l   gmod_MaxVecOfs(a5),\1
  82.                 dc.w    $6404           ; bra.s *+2
  83.                 gmodcall \1
  84.                 endm
  85.  
  86.  
  87. *** Use these macros if you are DEFINING a GMOD header.  This makes it
  88. *** easier if you don't happen to know the lengths of the various instructions
  89. *** by memory.
  90.  
  91. * Do-nothing entrypoint - stick this in entrypoints you don't need or can't support
  92. gmodnop         macro                   ; Do-nothing entry in a GMOD header
  93.                 rts
  94.                 nop
  95.                 endm
  96.  
  97. * Branch to some other location (makes the GMOD header act like a jump table)
  98. gmodbra         macro   ; <label>       ; 4-byte branch.
  99.                 jmp     \1(pc)          ; (Some assemblers would optimize down a bra.w.)
  100.                 endm
  101.  
  102. * The following macro is useful for a few entrypoints like GetNumSongs
  103. * where you just need to return a small constant value.
  104. gmodq           macro   ; const         ; Return quick constant
  105.                 moveq   #\1,d0
  106.                 rts
  107.                 endm
  108.  
  109.         endc
  110.